export default class loadingManager {
  static _manager = null;
  loadingComp = null;

  constructor() {
    loadingManager._manager = this;
  }

  static show() {
    const dom = loadingManager.getDom();
    loadingManager._manager.loadingComp = dom;
    document.body.appendChild(dom);
  }

  static hide() {
    const dom = loadingManager._manager.loadingComp;
    if (dom != null) {
      dom.style.opacity = 0;
      setTimeout(() => {
        document.body.removeChild(dom);
      }, 200);
      loadingManager._manager.loadingComp = null;
    }
  }

  static getDom() {
    const content = document.createElement("div");
    content.classList.add("loading-root");

    const image = document.createElement("div");
    image.classList.add("image");
    content.appendChild(image);

    return content;
  }
}
